<?php

namespace app\model;

use app\BaseModel;
use think\model\relation\BelongsTo;

/**
 * 教职工-测评任务用户表
 */
class WorkersTaskUserModel extends BaseModel
{
    protected $name = 'workers_task_user';

    /**
     * 关联任务
     * @return BelongsTo
     */
    public function task(): BelongsTo
    {
        return $this->belongsTo(WorkersTaskModel::class,'task_id')->bind([
            'task_name' => 'name',
            'task_start_time' => 'start_time',
            'task_end_time' => 'end_time',
            'task_rating_scale_count' => 'rating_scale_count',
            'result_read_auth',
            'user_name'
        ]);
    }

    /**
     * 关联量表
     * @return BelongsTo
     */
    public function ratingScale(): BelongsTo
    {
        return $this->belongsTo(RatingScaleModel::class,'rating_scale_id')->bind([
            'rating_scale_name'=>'name',
            'rating_scale_cover'=>'cover',
            'rating_scale_mode_id'=>'mode_id',
            'rating_scale_introduce'=>'introduce',
            'rating_scale_notice'=>'notice',
            'rating_scale_type_name'
        ]);
    }

    /**
     * 关联教职工用户表
     * @return BelongsTo
     */
    public function WorkersUser(): BelongsTo
    {
        return $this->belongsTo(WorkersUserModel::class,'uid')->bind([
            'user_name'=>'name',
            'age' => 'age',
            'sex' => 'sex',
            'birthday'
        ]);
    }

    /**
     * 关联教职工任务测评结果
     * @return BelongsTo
     */
    public function WorkersTaskUserResult(): BelongsTo
    {
        return $this->belongsTo(WorkersTaskUserResultModel::class,'result_id')->bind([
            'is_explain',
            'explain',
            'is_warning',
            'warning_id',
            'warning_factor_id',
            'answer_role',
            'is_valid',
            'TaskFactorScore',
            'answer_role',
            'total_score'
        ]);
    }
}